home *** CD-ROM | disk | FTP | other *** search
- package test.ui;
-
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.SystemColor;
- import java.awt.Toolkit;
- import java.awt.image.ImageProducer;
- import java.net.URL;
-
- class Logo extends Canvas {
- private Image fImage = this.loadImage("logo.gif");
- private int fWidth = 20;
- private int fHeight = 20;
-
- public Logo() {
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.fImage, 0);
-
- try {
- tracker.waitForAll();
- } catch (Exception var2) {
- }
-
- if (this.fImage != null) {
- this.fWidth = this.fImage.getWidth(this);
- this.fHeight = this.fImage.getHeight(this);
- }
-
- ((Component)this).setSize(this.fWidth, this.fHeight);
- }
-
- public Image loadImage(String name) {
- Toolkit toolkit = Toolkit.getDefaultToolkit();
-
- try {
- URL url = this.getClass().getResource(name);
- return toolkit.createImage((ImageProducer)url.getContent());
- } catch (Exception var4) {
- return null;
- }
- }
-
- public void paint(Graphics g) {
- this.paintBackground(g);
- if (this.fImage != null) {
- g.drawImage(this.fImage, 0, 0, this.fWidth, this.fHeight, this);
- }
-
- }
-
- public void paintBackground(Graphics g) {
- g.setColor(SystemColor.control);
- g.fillRect(0, 0, ((Component)this).getBounds().width, ((Component)this).getBounds().height);
- }
- }
-